from redis import StrictRedis, ConnectionPool

pool = ConnectionPool(host='localhost', port=6379, db=1)
redis = StrictRedis(connection_pool=pool)
redis.set('user1','Xiao3')

# ConnectionPool还支持通过url来构建
'''
创建Redis TCP 连接
redis://[:password]@host:port/db
创建Redis TCP+SSL连接
rediss；//[:password]@host:port/db
创建Redis UNIX socket 连接
unix：//[:password]@/path/to/socket.sock?db=db

其中，password部分如果有可以写，没有则可以省略
'''
# 示例
# url = 'redis://:foobared@localhost:6379/0'
url = 'redis://@localhost:6379/1'
pool = ConnectionPool.from_url(url)
redis = StrictRedis(connection_pool=pool)
redis.set('user2','Xiaobu')

